var timeU = {
    getDay: function () {
        var now = new Date().getTime()
        var hourT = 3600 * 1000
        var dayT = 3600 * 24 * 1000
        var day = Math.floor(now / dayT)
        var dayBegin = day * dayT - 8 * hourT
        var dayEnd = dayBegin + dayT
        return { begin: dayBegin, end: dayEnd }

    },
    getMonth: function () {
        var now = new Date().getTime()
        var hourT = 3600 * 1000
        var dayT = 3600 * 24 * 1000
        var monthT = dayT * 30
        var monthBegin
        var monthEnd
        var dayNum = new Date().getDate() - 1
        monthBegin = now - dayNum * dayT - (now % dayT) - 8 * hourT
        var monthNum = new Date().getMonth()
        var monthDayCount = 30
        switch (monthNum) {
            case 0:
                monthDayCount = 31
            case 1:
                monthDayCount = 28
            case 2:
                monthDayCount = 31
            case 3:
                monthDayCount = 30
            case 4:
                monthDayCount = 31
            case 5:
                monthDayCount = 30
            case 6:
                monthDayCount = 31
            case 7:
                monthDayCount = 31
            case 8:
                monthDayCount = 30
            case 9:
                monthDayCount = 31
            case 10:
                monthDayCount = 30
            case 11:
                monthDayCount = 31

        }
        monthEnd = monthBegin + (monthDayCount - 1) * dayT
        return { begin: monthBegin, end: monthEnd }
    }
}

module.exports = timeU